<?php
class Accreditation extends CActiveRecord
{
  public $early_from;
  public $early_current;

  public $elementary_from;
  public $elementary_to;

  public $secondary_from;
  public $secondary_to;

  public $currently_from;
  public $currently_to;

  public $grades_from;
  public $grades_to;

  public $whom;
  public $verifyCode;

	/**
	 * Returns the static model of the specified AR class.
	 * @return Accreditation the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'accreditation';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
      array('whom', 'safe'),
			array('early_from, early_current, elementary_from, elementary_to, secondary_from, secondary_to, currently_from, currently_to, grades_from, grades_to', 'required'),
			array('school_name, phone, fax, mailing_address, administrator_director, email, founded, grade_served, accreditation_early_education, accreditation_elementary, accreditation_secondary, accreditation_boarding_facility, accredited_date_granted, accredited_grades, accredited_joint_whom, accredited_joint_grade, renewal_date, expiration_date, joint_accreditation_planned, accreditation_protocol', 'required'),
			// array('school_name, phone, fax, mailing_address, administrator_director, email, founded, grade_served, accreditation_early_education, accreditation_elementary, accreditation_secondary, accreditation_boarding_facility, accredited_date_granted, accredited_grades, accredited_joint_whom, accredited_joint_grade, renewal_date, expiration_date, joint_accreditation_planned, accreditation_protocol', 'length', 'max'=>1000),
      array('verifyCode', 'CaptchaExtendedValidator', 'allowEmpty'=>!CCaptcha::checkRequirements()),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, user_id, date, school_name, phone, fax, mailing_address, administrator_director, email, founded, grade_served, accreditation_early_education, accreditation_elementary, accreditation_secondary, accreditation_boarding_facility, accredited_date_granted, accredited_grades, accredited_joint_whom, accredited_joint_grade, renewal_date, expiration_date, joint_accreditation_planned, accreditation_protocol', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
      'user' => array(self::BELONGS_TO, 'Users', 'user_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'user_id' => 'User',
			'date' => 'Date',
			'school_name' => 'School Name',
			'phone' => 'Phone',
			'fax' => 'Fax',
			'mailing_address' => 'Mailing Address',
			'administrator_director' => 'Administrator Director',
			'email' => 'Email',
			'founded' => 'Founded',
			'grade_served' => 'Grade Served',
			'accreditation_early_education' => 'Accreditation Early Education',
			'accreditation_elementary' => 'Accreditation Elementary',
			'accreditation_secondary' => 'Accreditation Secondary',
			'accreditation_boarding_facility' => 'Accreditation Boarding Facility',
			'accredited_date_granted' => 'Accredited Date Granted',
			'accredited_grades' => 'Accredited Grades',
			'accredited_joint_whom' => 'Accredited Joint Whom',
			'accredited_joint_grade' => 'Accredited Joint Grade',
			'renewal_date' => 'Renewal Date',
			'expiration_date' => 'Expiration Date',
			'joint_accreditation_planned' => 'Joint Accreditation Planned',
			'accreditation_protocol' => 'Accreditation Protocol',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('user_id',$this->user_id);
		$criteria->compare('date',$this->date,true);
		$criteria->compare('school_name',$this->school_name,true);
		$criteria->compare('phone',$this->phone,true);
		$criteria->compare('fax',$this->fax,true);
		$criteria->compare('mailing_address',$this->mailing_address,true);
		$criteria->compare('administrator_director',$this->administrator_director,true);
		$criteria->compare('email',$this->email,true);
		$criteria->compare('founded',$this->founded,true);
		$criteria->compare('grade_served',$this->grade_served,true);
		$criteria->compare('accreditation_early_education',$this->accreditation_early_education,true);
		$criteria->compare('accreditation_elementary',$this->accreditation_elementary,true);
		$criteria->compare('accreditation_secondary',$this->accreditation_secondary,true);
		$criteria->compare('accreditation_boarding_facility',$this->accreditation_boarding_facility,true);
		$criteria->compare('accredited_date_granted',$this->accredited_date_granted,true);
		$criteria->compare('accredited_grades',$this->accredited_grades,true);
		$criteria->compare('accredited_joint_whom',$this->accredited_joint_whom,true);
		$criteria->compare('accredited_joint_grade',$this->accredited_joint_grade,true);
		$criteria->compare('renewal_date',$this->renewal_date,true);
		$criteria->compare('expiration_date',$this->expiration_date,true);
		$criteria->compare('joint_accreditation_planned',$this->joint_accreditation_planned,true);
		$criteria->compare('accreditation_protocol',$this->accreditation_protocol,true);

		return new CActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,
		));
	}
}